(defun last-digits-of (x digits)
  (mod x (expt 10 digits)))

(defun pow-of-2 (pow)
  (if (= pow 1) 
      2
      (last-digits-of (* (pow-of-2 (1- pow)) 2) 10)))

(defun pow-of-2 (pow)
  (loop for i from 1 to pow for p = 2 then (mod (* p 2) 10000000000)   finally (return p)))

(defun probl97 ()
  (last-digits-of (+ (* 28433 (pow-of-2 7830457)) 1) 10))

